package com.D5Power.Editor.EditorWindow
{
	import com.D5Power.Editor.LuaEditor;
	import com.D5Power.Editor.Objects.NCharacterObject_MaEd;
	import com.D5Power.Objects.Effects.RoadPoint;
	import com.D5Power.Objects.GameObject;
	import com.D5Power.Objects.NCharacterObject;
	
	import flash.events.Event;
	
	import org.aswing.JButton;
	import org.aswing.JLabel;
	import org.aswing.JTextField;
	import org.aswing.ext.Form;
	
	public class RoadPointAttr extends ObjectAttr
	{
		private var _lua_name:JTextField;
		private var _mapid:JTextField;
		private var _uid:JTextField;
		
		/**
		 * @param	owner	主程序映射
		 * @param	obj		控制对象
		 */ 
		public function RoadPointAttr(owner:D5RpgEditor, obj:GameObject=null)
		{
			mytitle='地图传送点属性';
			super(owner, obj);
		}
		
		override protected function init(mode:uint=0):void
		{
			_box = new Form();
			
			// 姓名编辑
			_mapid = new JTextField((_obj as RoadPoint).toMap.toString(),10);
			var lable:JLabel = new JLabel('跳转到地图：',null,JLabel.LEFT);
			
			// UID编辑
			_uid = new JTextField((_obj as RoadPoint).toX.toString()+','+(_obj as RoadPoint).toY.toString(),10);
			var lable2:JLabel = new JLabel('跳转到坐标：',null,JLabel.LEFT);

			_box.addRow(lable,_mapid);
			_box.addRow(lable2,_uid);
			
			_box.setSizeWH(200,200);
			getContentPane().append(_box);
			super.init();
		}
		
		override protected function onSubmit(e:Event):void
		{
			
			var arr:Array = _uid.getText().split(',');
			if(arr.length!=2) _root.msg('提示','跳转坐标请以英文逗号分割。');
			(_obj as RoadPoint).toMap = int(_mapid.getText());
			(_obj as RoadPoint).toX= int(arr[0]);
			(_obj as RoadPoint).toY = int(arr[1]);
			super.onSubmit(e);
		}
		
		private function get TrueObj():NCharacterObject
		{
			return _obj as NCharacterObject;
		}
	}
}